package com.bw.shopping.controller;

import com.bw.common.core.domain.R;
import com.bw.shopping.domain.PostTable;
import com.bw.shopping.service.PostTableService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Author：尚志豪
 * @Package：com.bw.shopping.controller
 * @Project：ruoyiszh
 * @name：PostTableController
 * @Date：2024/12/28 13:29
 */
@RestController
@RequestMapping("/PostTable")
public class PostTableController {
    @Autowired
    private PostTableService postTableService;

    /**
     * 实现发帖功能
     */
    @PostMapping("/postingFunction")
    public R postingFunction(@RequestBody PostTable postTable)
    {
        postTableService.postingFunction(postTable);
        return R.ok("实现发帖功能");
    }
    /**
     * 回复功能
     */
    @PostMapping("/oneKeyRecovery")
    public R oneKeyRecovery(@RequestBody PostTable postTable)
    {
        postTableService.oneKeyRecovery(postTable);
        return R.ok("回复功能");
    }
    /**
     * 信息列表功能
     */
    @GetMapping("/informationListFunction")
    public R informationListFunction()
    {
        List<PostTable> list = postTableService.informationListFunction();
        return R.ok(list);
    }

    //////
    //////
    //////
    //////
    /**
     * 获取树形结构的根节点
     */
    @GetMapping("/tree")
    public List<PostTable> getTreeStructure() {
        return postTableService.getTreeStructure();
    }

    /**
     * 获取指定节点及其子节点的层级结构
     */
    @GetMapping("/level/{id}")
    public PostTable getNodeWithLevel(@PathVariable Long id) {
        return postTableService.getNodeWithLevel(id);
    }

    /**
     * 添加新节点
     */
    @PostMapping("/add")
    public PostTable addNode(@RequestBody PostTable postTable) {
        return postTableService.addNode(postTable);
    }

    /**
     * 更新节点
     */
    @PutMapping("/update")
    public PostTable updateNode(@RequestBody PostTable postTable) {
        return postTableService.updateNode(postTable);
    }

    /**
     * 删除节点
     */
    @DeleteMapping("/delete/{id}")
    public void deleteNode(@PathVariable Long id) {
        postTableService.deleteNode(id);
    }
}


